package com.fabriciojf.controller;

/**
 * ActionFactory
 *
 * @author Fabricio S Costa fabriciojf@gmail.com
 * @since 01/12/2009
 * @version 1.0
 */
public class ActionFactory {
    
    /** Creates a new instance of ActionFactory */
    public static Action create(String action) {
        Action actionObject = null;
        String nomeClass = "com.fabriciojf.action." + action + "Action";
        Class classe = null;
        Object objeto = null;
        try {
            classe = Class.forName(nomeClass);
            objeto = classe.newInstance();
        } catch(Exception ex) {
            return null;
        }
        
        if (!(objeto instanceof Action)) {
            return null;
        }
            
        actionObject = (Action) objeto;
        return actionObject;
    }
    
}
